﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApp.Code
{
    public class UploadContext
    {
        const string SP_Upload_UserName = "SP_Upload_UserName";
        const string SP_Upload_Folder = "SP_Upload_Folder";

        //public static void InitUserName(string userName)
        //{
        //    HttpCookie cookie = new HttpCookie(SP_Upload_UserName, userName);
        //    cookie.Expires = DateTime.Now.AddDays(1);
        //    HttpContext.Current.Response.SetCookie(cookie);
        //}
        public static string GetUploadUserName()
        {
            return HttpContext.Current.Request.QueryString["username"];
        }

        public static void InitUploadFolder(string uploadFolder)
        {
            HttpCookie cookie = new HttpCookie(SP_Upload_Folder, uploadFolder);
            //cookie.Expires = DateTime.Now.AddDays(1);
            HttpContext.Current.Response.AppendCookie(cookie);
        }
        public static string GetUploadFolder()
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies[SP_Upload_Folder];
            if (cookie != null)
                return cookie.Value;
            else
                return string.Empty;
        }
    }
}